#ifndef _PARSER_
#define _PARSER_

#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <map>
#include "ConfigFile.h"
#include "SwafStructs.h"
#include "RabinKarp.h"
#include "SendTcpPacket.h"
#include "HTTPRequest.h"

#define SLEEP_AFTER_RESET 1000
#define DEBUG

using namespace std;

class Parser
{
private:
	map<string,struct HTTP_SESSION> *_httpSessionsTable;   // pointer to the http sessions table
	string _file;
	Searcher *_sch;
	RabinKarp *_rk;
	u_short _serverPort;
	vector<string> _ignoreList;

public:
	Parser(map<string,struct HTTP_SESSION>*);
	virtual ~Parser(void);
	void init();
	void run();
	void buildHttpRequest(const string&);
	void buildHttpReply(const string&);
	int searchRequest(const string&);
	void action(struct HTTP_SESSION&,int,int);
	int reset(struct HTTP_SESSION&);
	void getServerPort();
	void loadIgnoredExtensions();
	bool checkExtension(string&);
};
#endif //_PARSER_
